class Solution {//leetcode429——N叉树的层序遍历
public:
    vector<vector<int>> levelOrder(Node* root) {
        vector<vector<int>> ret;
        queue<Node*> q;
        if(root==nullptr) return ret;
        q.push(root);
        while(!q.empty()){
            int level_cnt=q.size();
            vector<int> level;
            for(int i=0;i<level_cnt;i++){
                Node* t=q.front();
                q.pop();
                level.push_back(t->val);
                for(Node* child:t->children){
                    q.push(child);
                }
            }
            ret.push_back(level);
        }
        return ret;
    }
};